import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('pipe')
export class pipe extends Component {
    //x轴到多少会消失
    @property
    removeX:number = -347;   
    //速度
    @property
    speed:number = 50;
  
    start() {
    //一秒创建 一个主子
    // this.schedule(()=>{
    //     //设置y轴 在  top bottom 数字之间
    //     pipeDown.setPosition(pipeDown.position.x,this.getRandomIntHeight(),pipeDown.position.z)
    // },1)/
    }



    update(deltaTime: number) {
        for (const element of this.node.children) {
            element.setPosition(
                element.position.x - this.speed*deltaTime,
                element.position.y,element.position.z
            )
            //如果背景超出屏幕
            if(element.position.x<this.removeX){
                element.destroy()
            }
        }
    }
}


